package com.xy.manage.service.impl;


import java.util.List;
import java.util.Map;
import java.util.Date;
import com.xy.core.util.BeanUtil;
import com.xy.common.page.Pagination;
import com.xy.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.xy.manage.dao.TinfoDao;
import com.xy.manage.model.Tinfo;
import com.xy.manage.service.TinfoService;

@Service
@Transactional
public class TinfoServiceImpl extends BaseServiceImpl<Tinfo> implements
		TinfoService {
	private TinfoDao tinfoDao;

	public TinfoServiceImpl(TinfoDao paramAppRoleDao) {
		super(paramAppRoleDao);
		this.tinfoDao = paramAppRoleDao;
	}

	@Override
	public boolean checkExist(String paraName, String paraValue) {
		return tinfoDao.checkExist("Tinfo", paraName, paraValue);
	}

	@Override
	public List<Tinfo> getTinfo(Map<String, Object> map) {
		return tinfoDao.getTinfo(map);
	}
	@Override
	public Pagination getTinfoByPage(Map<String, Object> map, int pageNo,
			int pageSize) {
		// TODO Auto-generated method stub
		return tinfoDao.getTinfoByPage(map, pageNo, pageSize);
	}
	 
   @Override
	public Tinfo save(Tinfo tinfo) {
	//	tinfo.setModtime(new Date());
		if(tinfo.getInfoid()==null){
			//新增
        	return super.save(tinfo);
		}else{
			//更新
			Tinfo tinfo1=tinfoDao.get(tinfo.getInfoid());
			try {
				BeanUtil.copyNotNullProperties(tinfo1, tinfo);
			} catch (Exception e) {
				e.printStackTrace();
			}  
			return super.save(tinfo1);
		}
	}

	@Override
	public Pagination getWorkGuideByPage(int pageNo, int pageSize) {
		return tinfoDao.getWorkGuideByPage(pageNo, pageSize);
	}
}